<template>
  <div>
    <!-- 表格 -->
    <div>
      <el-table
        :data="orderData"
        height="calc(100vh - 200px)"
        stripe
        style="width: 100%">
        <el-table-column
          prop="id"
          label="订单编号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="orderTime"
          label="下单时间"
          width="180">
        </el-table-column>
        <el-table-column
          prop="total"
          label="总价">
        </el-table-column>
        <el-table-column
          prop="status"
          label="状态">
        </el-table-column>
        <el-table-column
          prop="customerId"
          label="顾客ID">
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button @click="toDetail(scope.row)" type="text" size="small">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="queryParams.page"
        :page-size="queryParams.pageSize"
        layout="total, prev, pager, next"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapActions, mapGetters, mapState } from "vuex";
export default {
  data() {
    return {
      // customerId:this.params.customerId,
      // id:this.$route.params.id,
      queryParams: {
        page: 1,
        pageSize: 10,
        // status:'',
        customerId: this.$route.params.id,
      },
    };
  },
  computed: {
    ...mapState("order", ["orderData"]),
    ...mapGetters('order',['total','orderData'])
  },
  methods: {
    ...mapActions("order", ["findAll"]),
    toDetail(){},
    handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.queryParams.page=val,
        this.findAll(this.queryParams)
      }
  },
  created() {
    // console.log(this.customerId)
    // console.log(this.$route)
    this.findAll(this.queryParams);
  },
  mounted() {},
};
</script>
<style lang="less" scoped>
</style>